<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS数据类型</title>
</head>
<body>
<script>
    <!--   基本数据类型     number string boolean undefined null    -->
    // 引用数据类型   object array function date ...........
    var num1 = 11;
    var num2 = 22;
    var num3 = 11.2
    console.log(num1, typeof num1, num2, typeof num2, num3, typeof num3)  // number


    var str1 = "qwertyui";
    var str2 = 'asdfg';
    console.log(str1, typeof str1, str2, typeof str2);   // string

    var test;
    console.log(test, typeof test)   //undefined

    var n = null
    console.log(n,typeof n)    //null 'object'


    var flag = false;
    console.log(flag,typeof flag)



//     对象
    let student = {}
    student.name="zs";
    student.age=11;
    student.class='三年级一班'


    console.log(student,typeof student)



    let student1 ={
        name:"xxxx",
        age:22
    }

    console.log(student1,typeof student1)
    // 在访问一个不存在的属性时，会返回undefined
    console.log(student1.play);
    student1.play="唱跳rap"
    console.log(student1.play);
    console.log(student1,typeof student1)


//     js数组
    let arr = ['zs',222,student1,true]
    console.log(arr[0] , arr[1],arr[2],arr[4])  // 访问越界的会返回undefined


//     0 null NaN undefined '' 转为boolean都为false
    console.log(Boolean(0))
    console.log(Boolean(''))
    console.log(Boolean(NaN))
    console.log(Boolean(undefined))
    console.log(Boolean('1'))
    console.log(Boolean('hello'))
    console.log(Boolean('    '))   // 有空格也不算空字符串 转为true


//     转换为数字
//     Number
    console.log(Number(true),typeof Number(true))
    console.log(Number(false),typeof Number(false))
    console.log(Number(3),typeof Number(3))
    console.log(Number('3'),typeof Number('3'))
    // NaN not a number 无法将这些内容转换为数字
    console.log(Number('ha'),typeof Number('ha'))
    console.log(Number('哈哈'),typeof Number('哈哈'))


</script>
</body>
</html>